﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WFNetLib;
using System.Net;

namespace 教室客户端
{
    public partial class Form4 : Form
    {
        public Form4(string _id)
        {
            InitializeComponent();
            id = _id;
        }
        string id;
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox2.Text != textBox3.Text)
            {
                MessageBox.Show("两次出入的新密码不一致，请重新输入");
                return;
            }
            try
            {
                WFHttpWebResponse WebResponse = new WFHttpWebResponse();
                string url = "http://wxpj.hrbeu.edu.cn/webAPI/API_ChangePassword.aspx?id=";
                url += id;
                url += "&oldpass=";
                url += textBox1.Text;
                url += "&newpass=";
                url += textBox2.Text;
                HttpWebResponse hr = WebResponse.CreateGetHttpResponse(url);
                string ret = WebResponse.Content;
                JSON_SubmitData SD = JsonSerializeHelper.DeSerialize<JSON_SubmitData>(ret);
                if (SD.success)//正常登陆
                {
                    MessageBox.Show("更改密码成功");
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show(SD.message);
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("未知错误" + ex.Message);
            }    
        }
    }
}
